# 
# Binary Search
# @author:Kelvin Pan
#


def binary_search (num_array,x):
	l=0 
	r=len(num_array) 
	while (l < r):
		mid=l+(r-l)/2; 
		if (num_array[mid] >= x):
			r=mid
		else:
			l=mid + 1
	return l
if __name__ == '__main__':
	result=binary_search([1], 9);
	result=binary_search([1], -1);
	result=binary_search([0, 1, 1, 3, 4, 5], 1);
	result=binary_search([0, 1, 1, 3, 4, 5], 10);
	print result 
